package com.example.project_01

import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class BdActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_bd)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        // 初始化视图
        val accountEditText: EditText = findViewById(R.id.account_edittext)
        val passwordEditText: EditText = findViewById(R.id.password_edittext)
        val loginButton: Button = findViewById(R.id.login_button)

        // 设置登录按钮点击事件
        loginButton.setOnClickListener {
            val account = accountEditText.text.toString().trim()
            val password = passwordEditText.text.toString().trim()

            // 简单的输入验证
            if (account.isEmpty() || password.isEmpty()) {
                Toast.makeText(this, "请输入账号和密码", Toast.LENGTH_SHORT).show()
                return@setOnClickListener
            }

            // 这里可以添加登录逻辑
            Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show()
            // 登录成功后可以跳转到主界面
            // startActivity(Intent(this, MainActivity::class.java))
            // finish()
        }
    }
}